<div class="toolbox divider nobr">
<#if authority.is(3) >	<input type="button" id="users_brw" class="button" value="浏览" /> 	</#if>
<#if authority.is(3,"1") >	<input type="button" id="users_add" class="button" value="添加" />	</#if>
<#if authority.is(3,"3") >	<input type="button" id="users_mod" class="button" value="修改" />	</#if>
<#if authority.is(3,"2") >	<input type="button" id="users_del" class="button" value="删除" />	</#if>
<#if authority.is(5,"9") >	<input type="button" id="users_auth" class="button" value="权限" />	</#if>
<#if authority.is(3,"3") >	<input type="button" id="users_pass" class="button" value="口令重置" />	</#if>
</div>

<script type="text/javascript">
	var mainPanel = 'mainPanel';
	var item_value ,del_ids;
	var webpage = 0; //0 通过用户管理页面 进入auth.setter.ftl ; 1 通过角色管理页面进入auth.setter.ftl 
	
	<#if authority.is(3) >	
		$('users_brw').addEvent('click', function(e){
			MUI.updateContent({
				'element':  $(mainPanel),
				'url':      '/auth/users.action',
			});
		});
	</#if>
	
	<#if authority.is(3,"1") >	
		$('users_add').addEvent('click', function(e){
			MUI.updateContent({
				'element':  $(mainPanel),
				'url':      '/auth/users.add.action',
				require: {
							css: [MUI.path.plugins + 'calendar/css/calendar.css'],			
							js: [MUI.path.plugins + 'calendar/scripts/calendar.js'],
							onload: function(){
								//myCal1 = new Calendar({ endtime: 'Y-m-d' }, { direction: 1, tweak: { x: 6, y: 0 }});;
								myCal1 = new Calendar({ endtime: 'Y-m-d' });;
							}	
						}	
			});
		});
	</#if>
	
	<#if authority.is(3,"3") >	
		$('users_mod').addEvent('click', function(e){
			if( users.checkIds()==1){
				var item = users.findFirstIds();
				item_value = item.value;		
				MUI.updateContent({
					'element':  $(mainPanel),
					'url':      '/auth/users.mod.action',
				require: {
							css: [MUI.path.plugins + 'calendar/css/calendar.css'],			
							js: [MUI.path.plugins + 'calendar/scripts/calendar.js'],
							onload: function(){
								//myCal1 = new Calendar({ endtime: 'Y-m-d' }, { direction: 1, tweak: { x: 6, y: 0 }});;
								myCal1 = new Calendar({ endtime: 'Y-m-d' });;
							}	
						}
				});
			}else{
				MUI.notification('<font color=red>错误：</font>只能选择一条记录进行修改！');
				return;
			}
		});
	</#if>
	
	<#if authority.is(3,"2") >	
		$('users_del').addEvent('click', function(e){
			if(users.checkIds()>=1){
				var confirm = confirmWindow('删除用户','确定要删除选中的用户？<input id="comfirm" type="button" value="确定" ><input id="cancel" type="button" value="取消" >');
				$('comfirm').addEvent('click',function(e){
					confirm.close();
					var itemarr = users.findIds();
					del_ids = users.arrCbToStr(itemarr);	
					 MUI.updateContent({
						'element':  $(mainPanel),
						'url':      '/auth/users.del.action'
					}); 
				});
				$('cancel').addEvent('click',function(e){
					confirm.close();
				});
				
			}else{
				MUI.notification('<font color=red>错误：</font>至少选择一条记录！');
				return;
			}
		});
	</#if>
	
	<#if authority.is(5,"9") >	
		$('users_auth').addEvent('click', function(e){
			if(users.checkIds()==1){
				var item = users.findFirstIds();
				item_value = item.value;		
				new MUI.Column({
					container: mainPanel,
					id: 'authTreeCol',
					placement: 'left',
					width: 200,
					resizeLimit: [100, 300]
				});
				
				new MUI.Column({
					container: mainPanel,
					id: 'authContentCol',
					placement: 'main',
					width: null,
					resizeLimit: [100, 300]
				});
				
				new MUI.Panel({
					header: false,
					id: 'authTreePanel',
					addClass: 'panelAlt',
					contentURL: '/auth/auth.setter.action',
					column: 'authTreeCol'
				});  
				
				new MUI.Panel({
					header: false,
					id: 'authContentPanel',
					addClass: 'panelAlt',
					contentURL: '/auth/users.auth.setter.action',
					column: 'authContentCol'
				});   
			}else{
				MUI.notification('<font color=red>错误：</font>只能选择一条记录权限设置！');
				return;
			}
		});
	</#if>	
	
	<#if authority.is(3,"3") >
		$('users_pass').addEvent('click', function(e){
			if(users.checkIds()>=1){
				var confirm = confirmWindow('密码重置','确定要重置选中的用户密码(新密码：123456)?<input id="comfirm" type="button" value="确定" ><input id="cancel" type="button" value="取消" >');
				$('comfirm').addEvent('click',function(e){
					confirm.close();
					var itemarr = users.findIds();
					choose_ids = users.arrCbToStr(itemarr);	
					try {
						var request = new Request.JSON({
							url: '/data/sc.action',
							onComplete: function(json,text) {
				 				if(json.error.errorcode==0){
									MUI.notification('密码重置成功！');
								}else{
									MUI.notification('<font color=red>错误：</font> '+json.error.retstring);
								}
							}
						}).get({"scid": "resetpassword","choose_ids":choose_ids});
					} catch (ex) {
						MUI.notification('<font color=red>错误：</font>访问失败('+ex.message+')');
					}
				}); //$('comfirm').addEvent...
			 
				$('cancel').addEvent('click',function(e){
					confirm.close();
				});
				
			}else{
				MUI.notification('<font color=red>错误：</font>至少选择一条记录！');
				return;
			}
		});
	</#if>
</script>
	